package nju.mscs.data.object;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;

public class ReturnBill implements Serializable{
	private User cashier;
	private VipConsumer vip;
	private Calendar time;
	private double money;
	private ArrayList<Goods> returnGoods=new ArrayList<Goods>();
	protected ReturnBill(User ca,VipConsumer vi){
		this.cashier=ca;
		this.vip=vi;
		this.time=Calendar.getInstance();
	}
	protected ReturnBill(User ca,VipConsumer vi,ArrayList<Goods> rg,double mo){
		this(ca,vi);
		returnGoods=rg;
		money=mo;
	}
	public boolean returnGoods(Goods g){
		return returnGoods.add(g);
	}
	public boolean searchGoods(String id){
		boolean result=false;
		for(Goods goods:returnGoods){
			if(goods.getId().equals(id))
				result=true;
		}
		return result;
	}
	public String print(){
		String text = "********************\n"+
		this.vip==null?("vip:"+this.vip.getName()+'\n'):""+
		"cachier:"+this.cashier==null?this.cashier.getName():"";
		for(Goods go:returnGoods){
			text+=go.getName()+'\n';
		}
		text+="ReturnMoney :"+money;
		return text;
	}
}
